package com.example.module_mine.register.viewmodel

import android.util.Log
import androidx.lifecycle.MutableLiveData
import com.example.lib_common.base.BaseViewModel
import com.example.module_mine.register.registernet.RegisterRePo
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class RegisterViewModel @Inject constructor(private val registerRePo: RegisterRePo) :
    BaseViewModel() {
    val registerlivedata by lazy {
        MutableLiveData<String>()
    }

    fun register(username: String, password: String) {
        execute(
            action = registerRePo.register(username, password),
            onFinish = {
                registerlivedata.value = "注册成功"
                Log.d("sss", "register: " + it.code + it.data.username + "注册成功")
            },
            onError = {
                registerlivedata.value = "注册失败，账号或密码已被注册"
                Log.d("sss", "register: " + it)
            }
        )
    }


}